package com.hs.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.entity.CourseRating;
import com.hs.mapper.CourseRatingMapper;
import com.hs.service.CourseRatingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseRatingServiceImpl implements CourseRatingService {
    @Autowired
    private CourseRatingMapper courseRatingMapper;
    @Override
    public int deleteById(Integer id) {
        return courseRatingMapper.deleteById(id);
    }

    @Override
    public int insertCourseRating(CourseRating record) {
        return courseRatingMapper.insertCourseRating(record);
    }

    @Override
    public int updateCourseRating(CourseRating record) {
        return courseRatingMapper.updateCourseRating(record);
    }

    @Override
    public CourseRating selectCourseRatingById(Integer id) {
        return courseRatingMapper.selectCourseRatingById(id);
    }

    @Override
    public PageInfo<CourseRating> selectCourseRatingByPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<CourseRating> cc = courseRatingMapper.selectCourseRatingAll();
        PageInfo<CourseRating> pageInfo = new PageInfo<>(cc);
        return pageInfo;
    }
}
